﻿<script src="../Scripts/AdminControllers/ChurchController.js"></script>
<div class="row" ng-controller="ChurchController">
    <div class="search-bar collapsed">
        <div class="form-group">
            <div class="input-group input-group-lg">
                <input type="text" class="form-control" placeholder="Type to search..." ng-model="searchkey" ng-change="Search()">
                <span class="input-group-btn">
                    <button class="btn btn-square btn-lg btn-default no-shadow close-search-bar" type="button" ng-click="searchkey='';Search();"><i class="zmdi zmdi-close"></i></button>
                </span>
            </div>
        </div>
    </div>
    <div class="col-md-12">
        <div class="bg-white bs-0 mb-20 widget">
            <div class="custom-grid-header">
                <div class="custom-grid-name">
                    Churches
                </div>
                <div class="custom-grid-menu">
                    <ul class="custom-grid-menu-ul pull-right">
                        <li class="custom-grid-menu-ul-li dropdown">
                            <a href="javascript:;" class="dropdown-toggle text-white"><i class="zmdi zmdi-sort"></i></a>
                            <ul class="dropdown-menu dropdown-menu-right animated flipInY" style="margin-top: 4px; padding: 0px; width: 220PX;overflow-y:scroll;">
                                <li class="sortmenu" ng-click="BindGridByPartition('00000000-0000-0000-0000-000000000000');" ng-class="{sortactive:PartitionId=='00000000-0000-0000-0000-000000000000'}">
                                    <div class="sort-col-1"><i class="zmdi zmdi-sort-by-alpha"></i></div>
                                    <div class="sort-col-2">All</div>
                                    <div class="clearfix"></div>
                                </li>
                                <li class="sortmenu" ng-repeat="data in zones" ng-click="BindGridByPartition(data.PartitionId);" ng-class="{sortactive:PartitionId==data.PartitionId}">
                                    <div class="sort-col-1"><i class="zmdi zmdi-sort-by-alpha"></i></div>
                                    <div class="sort-col-2">{{data.PartitionName}}</div>
                                    <div class="clearfix"></div>
                                </li>
                            </ul>
                        </li>
                        <li class="custom-grid-menu-ul-li" ng-click="ChangeView()">
                            <a href="javascript:;" class="text-white"><i class="zmdi zmdi-card-membership"></i></a>
                        </li>
                        <li class="custom-grid-menu-ul-li dropdown">
                            <a href="Church/PrintChurches?SearchKey={{searchkey}}&Sort={{sortby}}&SortMode={{sortmode}}&PartitionId={{PartitionId}}&DesignationId={{DesingationId}}" class="text-white" target="_blank" ><i class="zmdi zmdi-print"></i></a>
                        </li>
                        <li class="custom-grid-menu-ul-li" ng-click="toggle('add','')">
                            <a href="javascript:;" class="text-white"><i class="fa fa-plus-circle"></i></a>
                        </li>
                        <li class="custom-grid-menu-ul-li dropdown">
                            <a href="javascript:;" class="dropdown-toggle text-white"><i class="zmdi zmdi-sort"></i></a>
                            <ul class="dropdown-menu dropdown-menu-right animated flipInY" style="margin-top: 4px; padding: 0px; width: 220PX;">
                                <li class="sortmenu" ng-click="sortby='DEFAULT';sort()" ng-class="{sortactive:sortby=='DEFAULT'}">
                                    <div class="sort-col-1"><i class="zmdi zmdi-sort-by-alpha"></i></div>
                                    <div class="sort-col-2">Default</div>
                                    <div class="clearfix"></div>
                                </li>
                                <li class="sortmenu" ng-click="sortby='NAME';sort()" ng-class="{sortactive:sortby=='NAME'}">
                                    <div class="sort-col-1"><i class="zmdi zmdi-sort-by-alpha"></i></div>
                                    <div class="sort-col-2">Name</div>
                                    <div class="clearfix"></div>
                                </li>
                                <li class="sortmenu" ng-click="sortby='EMAIL';sort()" ng-class="{sortactive:sortby=='EMAIL'}">
                                    <div class="sort-col-1"><i class="zmdi zmdi-sort-by-alpha"></i></div>
                                    <div class="sort-col-2">Email</div>
                                    <div class="clearfix"></div>
                                </li>
                                <li class="sortmenu" ng-click="sortby='PHONE';sort()" ng-class="{sortactive:sortby=='PHONE'}">
                                    <div class="sort-col-1"><i class="zmdi zmdi-sort-by-alpha"></i></div>
                                    <div class="sort-col-2">Phone</div>
                                    <div class="clearfix"></div>
                                </li>
                                <li class="sortmenu" ng-click="sortby='CHURCHNO';sort()" ng-class="{sortactive:sortby=='CHURCHNO'}">
                                    <div class="sort-col-1"><i class="zmdi zmdi-sort-by-alpha"></i></div>
                                    <div class="sort-col-2">Refference Number</div>
                                    <div class="clearfix"></div>
                                </li>
                                <li class="sortmenu" ng-click="sortby='DESIGNATION';sort()" ng-class="{sortactive:sortby=='DESIGNATION'}">
                                    <div class="sort-col-1"><i class="zmdi zmdi-sort-by-alpha"></i></div>
                                    <div class="sort-col-2">Church Designation</div>
                                    <div class="clearfix"></div>
                                </li>
                                <li class="sortmenu" ng-click="sortby='ZONE';sort()" ng-class="{sortactive:sortby=='ZONE'}">
                                    <div class="sort-col-1"><i class="zmdi zmdi-sort-by-alpha"></i></div>
                                    <div class="sort-col-2">Church Zone</div>
                                    <div class="clearfix"></div>
                                </li>
                            </ul>
                        </li>
                    </ul>
                    <div class="clearfix"></div>
                </div>
                <div class="clearfix"></div>
            </div>
            <div class="widget-body">
                <div class="row">
                    <div class="col-md-12" ng-show="viewmode=='TABLE'">
                        <table class="table table-striped table-bordered">
                            <thead>
                                <tr>
                                    <th style="width: 8%">Church Id</th>
                                    <th style="width: 17%">Church Name</th>
                                    <th style="width: 15%">Designation</th>
                                    <th style="width: 15%">Zone</th>
                                    <th style="width: 15%">Contact No</th>
                                    <th style="width: 15%">Email</th>
                                    <th style="width: 15%">ACTION&nbsp;</th>
                                </tr>
                            </thead>
                            <tbody>
                                <tr ng-repeat="data in list">
                                    <td>
                                        <a class="links" href="Church/ChurchInfo?ChurchId={{data.ChurchId}}">{{data.ChurchNo}}</a>
                                    </td>
                                    <td>
                                        <a class="links" href="Church/ChurchInfo?ChurchId={{data.ChurchId}}">{{data.ChurchName}}</a>
                                    </td>
                                    <td>{{data.Designation.DesignationName}} </td>
                                    <td>{{data.OrganizationPartition.PartitionName}}</td>
                                    <td>{{data.ContactNo}}</td>
                                    <td>{{data.Email}}</td>
                                    <td>
                                        <div class="btn-group-sm" role="group" aria-label="Second group">
                                            <button type="button" class="btn btn-info waves-effect" ng-click="toggle('edit',data.ChurchId);"><i class="fa fa-pencil"></i></button>
                                            <button type="button" class="btn btn-danger waves-effect" ng-click="delete(data.ChurchName,data.ChurchId)"><i class="fa fa-trash"></i></button>
                                            <a class="btn btn-success waves-effect" href="Church/ChurchInfo?ChurchId={{data.ChurchId}}"><i class="fa fa-info-circle"></i></a>
                                            <a class="btn btn-purple waves-effect" target="_blank" href="ChurchWorkers/PrintChurchWorkerDetails?ChurchId={{data.ChurchId}}"><i class="zmdi zmdi-print"></i></a>
                                        </div>
                                    </td>
                                </tr>
                            </tbody>
                        </table>
                    </div>
                    <div class="col-md-12" ng-show="viewmode=='CARD'">
                        <ul class="card">
                            <li ng-repeat="data in list">
                                <div class="card-container">
                                    <div class="card-container-row">
                                        <div class="card-image">
                                            <img class="media-object mo-lg  mCS_img_loaded" src="~/Images/_ErrorImage.png" actual-image="{{data.Image}}" on-error-src="~/Images/_LoadImage.jpg">
                                        </div>
                                        <div class="card-details">
                                            <div class="card-details-row-1"><i class="fa fa-user"></i> {{data.ChurchName}}</div>
                                            <div class="card-details-row-2"><i class="fa fa-phone"></i> {{data.ContactNo}}</div>
                                            <div class="card-details-row-3"><i class="zmdi zmdi-email"></i> {{data.Email}}</div>
                                        </div>
                                        <div class="clearfix"></div>
                                    </div>
                                    <div class="card-action">
                                    </div>
                                </div>
                            </li>
                        </ul>
                    </div>
                    <div gridloader></div>
                    <div nodata></div>
                </div>
                <div ng-show="list.length > 0" style="padding-right: 10px; text-align: right;">
                    <div pagination="" page="currentPage" max-size="10" on-select-page="setPage(page)" boundary-links="true" total-items="filteredItems" items-per-page="entryLimit" class="pagination-small" previous-text="«" next-text="»"></div>
                </div>
            </div>
        </div>
    </div>
    <div class="modal fade bs-example-modal-panel" tabindex="-1" id="Church" role="dialog" aria-labelledby="myPanelModalLabel">
        <div class="modal-dialog" role="document">
            <div class="modal-content">
                <div class="modal-header bg-primary">
                    <button type="button" class="close" data-dismiss="modal" aria-label="Close"><span aria-hidden="true">&times;</span></button>
                    <h4 class="modal-title" id="myAnimationModalLabel">{{title}}</h4>
                </div>
                <form name="fromvalidate" novalidate>
                    <div class="modal-body">
                        <div class="form-group">
                            <input type="hidden" ng-model="Church.ChurchId" />
                            Church Name
                            <input type="text" class="form-control" name="ChurchhName" ng-model="Church.ChurchName" ng-maxlength="100" ng-required="true" ng-minlength="4">
                        </div>
                        <div class="form-group">
                            Contact No
                            <input type="text" class="form-control" name="ContactNo" ng-model="Church.ContactNo" maxlength="10" value="{{Church.ChurchContact.ContactNo}}" ng-maxlength="10" ng-minlength="10">
                        </div>
                        <div class="form-group">
                            Church Type
                            <select ng-model="Church.OrganizationId"
                                    ng-options="obj.Departmentsid as obj.DepartmentName for obj in minitrialtype"
                                    class="form-control"
                                    ng-required="true"></select>
                        </div>
                        <div class="form-group">
                            Church Designation
                            <select ng-model="Church.DesignationId"
                                    ng-options="obj.DesignationId as obj.DesignationName for obj in designation"
                                    class="form-control"
                                    ng-required="true"></select>
                        </div>
                        <div class="form-group">
                            Church Zone
                            <select ng-model="Church.PartitionId"
                                    ng-options="obj.PartitionId as obj.PartitionName for obj in zones"
                                    class="form-control"
                                    ng-required="true"></select>
                        </div>
                        <div class="form-group">
                            Grade
                            <select ng-model="Church.GradeId"
                                    ng-options="obj.GradeId as obj.GradeName for obj in grade"
                                    class="form-control"
                                    ng-required="false"></select>
                        </div>

                        <div class="form-group">
                            <label class="checkbox-inline checkbox-custom mr-15">
                                <input type="checkbox" value="remember" name="logincreate" ng-model="Church.IsLoginCreated" id="exampleCheckboxEmail" checked="{{Church.IsLoginCreated}}">
                                <label for="exampleCheckboxEmail">Create Login</label>
                            </label>
                        </div>
                        <div class="form-group">
                            Email
                            <input type="email" class="form-control" name="email" ng-model="Church.Email" value="{{Church.Email}}" ng-required="Church.IsLoginCreated">
                        </div>

                        <div class="form-group">
                            Country
                            <select ng-model="Church.ChurchContact.CountryId"
                                    ng-options="obj.CountryId as obj.CountryName for obj in countries"
                                    class="form-control" ng-required="true"></select>
                        </div>
                        <div class="form-group">
                            State
                            <select ng-model="Church.ChurchContact.StateId"
                                    ng-options="obj.StateId as obj.StateName for obj in states"
                                    class="form-control"
                                    ng-required="true"></select>
                        </div>
                        <div class="form-group">
                            Address Line 1
                            <textarea ng-model="Church.ChurchContact.Addressline1" class="form-control" value="{{Church.ChurchContact.Addressline1}}" ng-required="true"></textarea>
                        </div>
                        <div class="form-group">
                            Address Line 2
                            <textarea ng-model="Church.ChurchContact.Addressline2" class="form-control" value="{{Church.ChurchContact.Addressline2}}"></textarea>
                        </div>
                        <div class="form-group">
                            Pincode
                            <input type="text" class="form-control" name="Pincode" value="{{Church.ChurchContact.Pincode}}" ng-model="Church.ChurchContact.Pincode" value="Church.ChurchContact.Pincode" ng-maxlength="6" ng-minlength="6">
                        </div>
                        <div class="row">
                            <div class="col-md-6">
                                <div class="form-group">
                                    Church Image 
                                    <input type="file" onchange="angular.element(this).scope().fileChangedChurch(event)" class="filestyle" data-buttonname="btn-primary" data-iconname="zmdi zmdi-file-text" />
                                </div>
                             </div>
                            <div class="col-md-6">
                                <img class="media-object mo-lg img-responsive mCS_img_loaded" src="~/Images/_ErrorImage.png" actual-image="{{Church.Image}}" on-error-src="~/Images/_LoadImage.jpg">
                            </div>
                            <div class="clear"> </div>
                        </div>
                    </div>
                    <div class="modal-footer">
                        <button type="button" class="btn btn-danger" data-dismiss="modal">Close</button>
                        <button type="button" class="btn btn-primary" ng-disabled="fromvalidate.$invalid || buttonstate" ng-click="save(modelstate);">Save</button>
                    </div>
                </form>
            </div>
        </div>
    </div>
</div>
